﻿#pragma once

#include <map>
#include "HiUnSafeSmartHeapList.h"

class HiUnSafeSmartHeapListImpl {
private:
	class HiIndex {
	public:
		HiIndex() {}
		HiIndex(int index, bool isUsing, void* data) {
			this->index = index;
			this->isUsing = isUsing;
			this->data = data;
		}
	public:
		int index;
		bool isUsing;
		void* data;
	};
public:
	HiUnSafeSmartHeapListImpl();
	~HiUnSafeSmartHeapListImpl();
public:
	void Init(int count, const HiUnSafeSmartHeapList::ALLOC_FUN& allocFun, const HiUnSafeSmartHeapList::RELEASE_FUN& releaseFun);
public:
	void* CreateData();
	void Destory(void* t);
	int WaterLevel();
private:	
	typedef std::pair<int, HiIndex*>  Itor;
private:
	std::map<int, HiIndex*> memorys;
	std::map<void*, HiIndex*> memoryPtrs;
	int memorySize;
	HiUnSafeSmartHeapList::RELEASE_FUN releaseFunc;
};
